﻿@using Microsoft.AspNetCore.Identity
@using Microsoft.AspNetCore.Mvc.TagHelpers
@using Passwordless.AdminConsole.Components.Layouts
@using Passwordless.AdminConsole.Helpers
@using Passwordless.AdminConsole.Identity
@inject SignInManager<ConsoleAdmin> signinManager
@inject IFileVersionProvider FileVersionProvider

@{
    var signedIn = signinManager.IsSignedIn(User);
}
<!DOCTYPE html>
<html lang="en" class="h-full">

<head>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <title>@ViewData["Title"] - Admin Console - Bitwarden Passwordless.dev</title>
    <link rel="stylesheet" href="~/css/site.css" asp-append-version="true"/>
    <link rel="stylesheet" href="~/css/tailwind.css" asp-append-version="true"/>
    <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
    <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
    <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
    <link rel="manifest" href="/site.webmanifest">
    @Html.ImportMap(new Dictionary<string, string> { ["vue"] = "/lib/vue/vue.mjs" }, FileVersionProvider)
    @await RenderSectionAsync("Head", false)
    @Html.RenderPartialSectionScripts()
    <script async src="@Url.Content("~/lib/es-module-shims/es-module-shims.js")" asp-append-version="true"></script>
    <script src="@Url.Content("~/lib/passwordless/passwordless.umd.min.js")" asp-append-version="true"></script>
</head>

<body class="h-full bg-gray-50">
<div class="page">
    @if (signedIn)
    {
        <div id="sidebar" class="hidden lg:fixed lg:inset-y-0 lg:flex lg:flex-col bg-primary-700 w-64">
            <component type="typeof(LinkHome)" param-Class="@("flex flex-shrink-0 items-center p-5 pb-3 pr-10 gap-1")" param-Size="@LinkHome.Sizes.Large" render-mode="Static" />
            <component type="typeof(NavMenu)" render-mode="ServerPrerendered" />
        </div>
        <div id="navbar-mobile" class="navbar-mobile">
            <button id="btn-sidebar-open" type="button" class="-ml-0.5 -mt-0.5 inline-flex h-12 w-12 items-center justify-center rounded-md text-gray-500 hover:text-gray-900 focus:outline-none focus:ring-2 focus:ring-inset focus:ring-blue-500">
                <span class="sr-only">Open sidebar</span>
                <component type="typeof(HamburgerIcon)" render-mode="Static" />
            </button>
        </div>

        <!-- Close button for the sidebar -->
        <div class="hidden absolute inset-0 bg-black opacity-50 z-40" id="sidebar-overlay"></div>

        <div class="content-container-authorized">
            <main>
                <div class="page-header-container">
                    @if (ViewData["HideTitle"] == null)
                    {
                        <h1 class="text-2xl font-semibold text-gray-900 mb-8">@ViewData["Title"]</h1>
                    }
                </div>
                <div class="page-content-container">
                    @RenderBody()
                </div>
            </main>
        </div>
    }
    else
    {
        <div class="sidebar-anonymous">
            <component type="typeof(LinkHome)" param-Size="@LinkHome.Sizes.Small" render-mode="Static" />
        </div>
        <div class="content-container-anonymous">
            <main>
                @RenderBody()
            </main>
        </div>
    }
</div>
    
<script type="text/javascript" src="~/js/core.js" asp-append-version="true"></script>
@await RenderSectionAsync("Scripts", false)
</body>
</html>
